package com.ls.demo.service;

import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ls.demo.entity.Metrics;
import com.ls.demo.entity.Notice;
import com.ls.demo.mapper.MetricsMapper;
import com.ls.demo.mapper.NoticeMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MetricsService {
    @Resource
    private MetricsMapper metricsMapper;

    public void add(Metrics metrics) {
        metricsMapper.insert(metrics);
    }

    public void updateById(Metrics metrics) {
        metricsMapper.updateById(metrics);
    }

    public void deleteById(Integer id) {
        metricsMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids) {
            metricsMapper.deleteById(id);
        }
    }

    public Metrics selectById(Integer id) {
        return metricsMapper.selectById(id);
    }

    public List<Metrics> selectAll(Metrics metrics) {
        return metricsMapper.selectAll(metrics);
    }

    public PageInfo<Metrics> selectPage(Metrics metrics, Integer pageNum, Integer pageSize) {
        System.out.println(metrics.getMetrics_name());
        PageHelper.startPage(pageNum, pageSize);
        List<Metrics> list = metricsMapper.selectAll(metrics);
        return PageInfo.of(list);
    }
}
